// 模块：客户，供应商
import axios from 'axios'
const modelUrl = '/produce'
// 客户
export interface CustomerReq {
  customerId?: string
  customerName: string
  customerAddress?: string
  taxNo?: string
  bankAccount?: string
  payeeAcctBank?: string
  contactName?: string
  contactPhone?: string
  remark?: string
}
export interface CustomerRes {
  currentPage?: number
  pageSize?: number
  totalPage?: number
  totalCount?: number
  list: CustomerResItem[]
}
export interface CustomerResItem {
  Name?: string
  customerId?: string
  customerName: string
  customerAddress: string
  taxNo: string
  bankAccount: string
  payeeAcctBank: string
  contactName: string
  contactPhone: string
  remark: string
  createdDt?: string
  createdBy?: string
  updatedBy?: string
  updatedDt?: string
  index?: number // 导出的序号
}
export interface CustomerListSearch {
  customerName?: string
  taxNo?: string
  contactName?: string
  orderBy?: number
}
export function editCustomer(data: CustomerReq) {
  return axios.post<CustomerRes | string>(modelUrl + '/erpCustomerAdit', data)
}

export function delCustomer(data: { customerId: string }) {
  return axios.post<object>(modelUrl + '/erpCustomerDel', data)
}

export function getCustomerDetail(data: { customerId: string }) {
  return axios.post<CustomerRes>(modelUrl + '/erpCustomerDetail', data)
}

export function getCustomerAllList(data?: CustomerListSearch) {
  return axios.post<CustomerRes>(modelUrl + '/erpCustomerList', data)
}

export function getCustomerPageList(data: CustomerListSearch) {
  return axios.post<CustomerRes>(modelUrl + '/erpCustomerPage', data)
}

export function batchDelCustomer(data: { idList: string[] }) {
  return axios.post<CustomerRes>(modelUrl + '/erpCustomerDelBatch', data)
}

// 供应商
export interface SupplierReq {
  supplierId?: string
  supplierName: string
  supplierAddress?: string
  taxNo?: string
  bankAccount?: string
  payeeAcctBank?: string
  contactName?: string
  contactPhone?: string
  remark?: string
}
export interface SupplierRes {
  currentPage?: number
  pageSize?: number
  totalPage?: number
  totalCount?: number
  list: SupplierResItem[]
}
export interface SupplierResItem {
  Name?: string
  supplierId?: string
  supplierName?: string
  supplierAddress?: string
  taxNo?: string
  bankAccount?: string
  payeeAcctBank?: string
  contactName?: string
  contactPhone?: string
  remark?: string
  createdBy?: string
  createdDt?: string
  updatedBy?: string
  updatedDt?: string
  index?: number // 导出的序号
}
export interface SupplierListSearch {
  supplierId?: number
  tenantId?: number
  supplierName?: string
  supplierAddress?: string
  taxNo?: string
  bankAccount?: string
  payeeAcctBank?: string
  contactName?: string
  contactPhone?: string
  remark?: string
  currentPage?: number
  pageSize?: number
  orderBy?: number
}
export function editSupplier(data: SupplierReq) {
  return axios.post<string>(modelUrl + '/erpSupplierAdit', data)
}

export function delSupplier(data: { supplierId: string }) {
  return axios.post<object>(modelUrl + '/erpSupplierDel', data)
}

export function getSupplierDetail(data: { supplierId: string }) {
  return axios.post<SupplierRes>(modelUrl + '/erpSupplierDetail', data)
}

export function getSupplierAllList(data?: SupplierListSearch) {
  return axios.post<SupplierRes>(modelUrl + '/erpSupplierList', data)
}

export function getSupplierPageList(data?: SupplierListSearch) {
  return axios.post<SupplierRes>(modelUrl + '/erpSupplierPage', data)
}

export function batchDelSupplier(data?: { idList: string[] }) {
  return axios.post<SupplierRes>(modelUrl + '/erpSupplierDelBatch', data)
}
